package com.example.auth.service;

import com.example.common.plugins.authentication.ExampleUserInfoService;
import com.example.common.plugins.authentication.MobileUserDetailService;
import com.example.starter.util.Response;
import com.example.system.api.UserApi;
import com.example.system.dto.UserInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Service;

/**
 * @author 王令
 * @since 2022/12/1 20:56
 */
@Service
@RequiredArgsConstructor
public class ExampleMobileUserDetailService implements MobileUserDetailService, ExampleUserInfoService {

    private final UserApi userApi;

    @Override
    public UserDetails loadUserByMobile(String phone) {
        Response<UserInfo> response = userApi.loadByMobilePhone(phone);
        return getUserDetailsInfo(response);
    }
}
